package com.cy.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cy.pojo.Equipment;
import com.cy.mapper.EquipmentMapper;
import com.cy.pojo.Equipment;
import com.cy.pojo.User;
import com.cy.service.EquipmentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author cy
 * @since 2021-11-21
 */
@Service
public class EquipmentServiceImpl extends ServiceImpl<EquipmentMapper, Equipment> implements EquipmentService {

    @Autowired
    private EquipmentMapper mapper;

    @Override
    public List<Equipment> queryPage(Integer pageNumber) {
        Page<Equipment> EquipmentPage = new Page<Equipment>(pageNumber,5);
        List<Equipment> Equipments = mapper.selectPage(EquipmentPage,new QueryWrapper<Equipment>().eq("status",1)).getRecords();
        return Equipments;
    }

    @Override
    public List<Equipment> queryPage(Integer pageNumber, Integer size) {
        Page<Equipment> EquipmentPage = new Page<Equipment>(pageNumber,size);
        List<Equipment> Equipments = mapper.selectPage(EquipmentPage,new QueryWrapper<Equipment>().eq("status",1)).getRecords();
        return Equipments;
    }

    @Override
    public List<Equipment> queryPage(Integer pageNumber, String name) {
        Page<Equipment> Page = new Page<Equipment>(pageNumber,5);
        List<Equipment> equipment = mapper.selectPage(Page, new QueryWrapper<Equipment>()
                .eq("status", 1)
                .like("name",name)
        ).getRecords();
        return equipment;
    }
}
